package com.woniuxy02;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

/**
 * @author 作者
 * @create 2025-11-05 14:12
 */
public class Test02 {
    public static void main(String[] args) throws ParseException {
        Date date = new Date();
        System.out.println(date);
        //当前日+1天
        Calendar calendar=Calendar.getInstance();
        System.out.println(calendar);
        calendar.add(Calendar.YEAR, 1);
        System.out.println(calendar);
        calendar.add(Calendar.MONTH, -1);
        System.out.println(calendar);
//        System.out.println(calendar.get(100));
    }

    private static void test01() {
        Date date = new Date();
        System.out.println(date.getYear()+1900);
        System.out.println(date.getMonth()+1);

        //创建日历对象
        Calendar calendar = Calendar.getInstance();
        //获取日历的年的部分
        System.out.println(calendar.get(1));
        //获取日历的月的部分
        System.out.println(calendar.get(2)+1);
        //获取日历的日（本月的第几天）的部分
        System.out.println(calendar.get(5));
        System.out.println(calendar.get(Calendar.YEAR));
        System.out.println(calendar.get(Calendar.MONTH));
        System.out.println(calendar.get(Calendar.DAY_OF_MONTH));
        System.out.println(calendar.get(Calendar.DATE));
        System.out.println(calendar.get(Calendar.DAY_OF_YEAR));

    }

}
